Skip to content

Add an optional workflow that runs the CUDA GPU kernel test on a simulated H100 - #1884

Merged
danielpeter merged 1 commit into
SPECFEM:develfrom
saqibkh:add-gpu-sim-ci
Nov 13, 2026
Merged

danielpeter merged 1 commit into
SPECFEM:develfrom
saqibkh:add-gpu-sim-ci

Conversation

@saqibkh

@saqibkh saqibkh commented Nov 12, 2026

Copy link
Copy Markdown

CI.yml compiles the CUDA build ("Test on linux w/ CUDA") but cannot run it, because the hosted runners have no GPU. The GPU code path is already tested on an emulated device through the ROCm HIP-CPU jobs ("Test 5b" and "Test 6b"), but those run the HIP build. This adds a separate, optional workflow .github/workflows/gpu-sim.yml that runs the same test as "Test 5b" (homogeneous acoustic kernel, GPU: true) on the CUDA build, on a simulated NVIDIA H100 using PantheonSim (no GPU needed). I am the author of PantheonSim, so please weigh this accordingly.

The job is modelled on linuxTest_5b and uses the existing .github/scripts/run_tests.sh unchanged. It does not touch any source file or CI.yml, and is not meant to be a required check. A simulator cannot reproduce hardware-specific behavior or timing, so it complements real-GPU testing and does not replace it.

What it does:

  • installs the CUDA 13.0 toolkit and the simulated H100 (pantheongpu/setup-pantheonsim, pinned by SHA), plus gfortran and Open MPI from apt
  • configures with --with-cuda=cuda12, which selects GENCODE_90 (sm_90 plus compute_90 PTX); the simulator runs the PTX. cuda13, as in the compile job, selects the Blackwell target, which an H100 cannot load. The Makefile already links --cudart=shared, which the simulator needs.
  • passes FLAGS_CHECK equal to the gfortran default from flags.guess minus -ffpe-trap=invalid,zero,overflow. The simulator runs device code on host threads, which inherit the trap mask, so the first inf/NaN in a kernel kills the solver with SIGFPE. This does not happen on a real GPU; it is a simulator limitation, not a SPECFEM problem, and the override can be dropped once the simulator handles it.
  • sets IMAIN = ISTANDARD_OUTPUT as run_build.sh does, builds only xdecompose_mesh, xgenerate_databases, xspecfem3D and xcombine_vol_data_vtk with -j3
  • runs TESTDIR=EXAMPLES/applications/homogeneous_acoustic/ RUN_KERNEL=true GPU=true ./.github/scripts/run_tests.sh under vgpu run, so the rho and kappa kernel maxima are checked against REF_KERNEL/ (0.1%), for the plain run and again with UNDO_ATTENUATION_AND_OR_PML
  • runs on manual dispatch and on pull requests to devel that touch src/, setup/, the configure/Makefile inputs, this example, run_tests.sh or the workflow, with a concurrency group that cancels superseded runs

Measured:

  • Run on my fork: https://github.com/saqibkh/specfem3d/actions/runs/43237758263 . It passed: both kernel checks printed "testing kernel values: all good" (rho 1.818e-10 and kappa 3.608e-12 in the plain run and in the UNDO_ATTENUATION_AND_OR_PML rerun), and the script ended with "all good".
  • The job took about 49 minutes: about 19.5 for the simulator and toolkit setup on a cold cache (shorter once cached), 2 for the build and about 27 for the test step.
  • Locally the simulated run gives rho 1.81843957E-10 and kappa 3.60817235E-12 (relative differences 1.5e-07 and 2.9e-06), and 1.81844081E-10 / 3.60816780E-12 with UNDO_ATTENUATION_AND_OR_PML. The same test built for sm_80 on a real RTX 3060 gives relative differences of 2.3e-07 / 4.2e-07 and 9.1e-07 / 3.4e-06.
  • As a check that the test notices wrong GPU results, I scaled p_dot_dot by 1.01 in kernel_3_acoustic_cuda_device: the kernel check then fails (rho 2.1E+12 against 1.8E-10) and the job exits 1.

Not covered:

  • Only the homogeneous acoustic kernel test (one process, NPROC = 1). The "6b" halfspace kernel test also works under the simulator with mpirun -np 4 (each rank gets its own simulated device; a 20-step check ran cleanly), but at 700 steps per run with four ranks on a 4-core runner it would take well over an hour, so I left it out.
  • Elastic, poroelastic, PML, fault and LTS kernels, the seismogram comparisons (REF_SEIS) and other examples are not run on the GPU path.
  • Only one GPU architecture (H100) and one CUDA version (13.0).

@saqibkh

saqibkh commented Nov 13, 2026

Copy link
Copy Markdown
Author

The red Azure checks (SPECFEM.specfem3d (Compilation Default GCC) and (Compilation CUDA 12 latest)) don't come from this PR, which only adds .github/workflows/gpu-sim.yml. Azure never reads that file. Both jobs use vmImage: 'ubuntu-latest', which moved to Ubuntu 26.04 on October 19 (the job log has a "Remote machine provider issue" note about it). On 26.04 (GCC 15, newer OpenMPI), configure --with-mpi now stops at configure: error: MPI header not found; try setting MPI_INC. The ubuntu-22.04 jobs in the same run passed. The last Azure run on devel was on October 9, before the image change, so I'd expect devel to fail the same way on its next run. Pinning those two jobs to ubuntu-24.04, or setting MPI_INC for 26.04, should fix it.

@danielpeter

Copy link
Copy Markdown
Member

thanks for this contribution! i hoped years ago for something like this - nice to see it now working 😄

and i'll go over the other checks to see what's going on. probably some runner OS updates...

@danielpeter
danielpeter merged commit 7e77ed7 into SPECFEM:devel Nov 13, 2026
43 of 49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants